home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / The GIMP 2.2.8 / gimp-2.2.8-i586-setup.exe / {app} / share / gimp / 2.0 / scripts / camo.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2005-06-30  |  3.7 KB  |  106 lines

  1. ;
  2. ;
  3. ;
  4. ; Chris Gutteridge (cjg@ecs.soton.ac.uk)
  5. ; At ECS Dept, University of Southampton, England.
  6.  
  7. ; This program is free software; you can redistribute it and/or modify
  8. ; it under the terms of the GNU General Public License as published by
  9. ; the Free Software Foundation; either version 2 of the License, or
  10. ; (at your option) any later version.
  11. ; This program is distributed in the hope that it will be useful,
  12. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. ; GNU General Public License for more details.
  15. ; You should have received a copy of the GNU General Public License
  16. ; along with this program; if not, write to the Free Software
  17. ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19.  
  20. (define (script-fu-camo-pattern inSize inGrain inColor1 inColor2 inColor3 inSmooth inFlatten)
  21.  
  22.   (let* (
  23.         (theWidth inSize)
  24.         (theHeight inSize)
  25.         (theImage (car (gimp-image-new theWidth theHeight RGB)))
  26.         (baseLayer (car (gimp-layer-new theImage theWidth theHeight RGBA-IMAGE "Background" 100 NORMAL-MODE)))
  27.         (thickLayer)
  28.         (thinLayer)
  29.         (theBlur)
  30.         )
  31.  
  32.         (gimp-image-add-layer theImage baseLayer 0)
  33.  
  34.         (set! thickLayer (car (gimp-layer-new theImage theWidth theHeight RGBA-IMAGE "Camo Thick Layer" 100 NORMAL-MODE)))
  35.         (gimp-image-add-layer theImage thickLayer 0)
  36.  
  37.         (set! thinLayer (car (gimp-layer-new theImage theWidth theHeight RGBA-IMAGE "Camo Thin Layer" 100 NORMAL-MODE)))
  38.         (gimp-image-add-layer theImage thinLayer 0)
  39.  
  40.     (gimp-context-push)
  41.  
  42.         (gimp-selection-all theImage)
  43.         (gimp-context-set-background inColor1)
  44.         (gimp-drawable-fill baseLayer BACKGROUND-FILL)
  45.  
  46.         (plug-in-solid-noise TRUE theImage thickLayer 1 0 (rand 65536) 1 inGrain inGrain)
  47.         (plug-in-solid-noise TRUE theImage thinLayer 1 0 (rand 65536) 1 inGrain inGrain)
  48.         (gimp-threshold thickLayer 127 255)
  49.         (gimp-threshold thinLayer 145 255)
  50.  
  51.     (set! theBlur (- 16 inGrain))
  52.  
  53.         (gimp-context-set-background inColor2)
  54.         (gimp-by-color-select thickLayer '(0 0 0) 127 CHANNEL-OP-REPLACE  TRUE FALSE 0 FALSE)
  55.         (gimp-edit-clear thickLayer)
  56.         (gimp-selection-invert theImage)
  57.         (gimp-edit-fill thickLayer BACKGROUND-FILL)
  58.         (gimp-selection-none theImage)
  59.         (if (= inSmooth TRUE)
  60.         (script-fu-tile-blur theImage thickLayer theBlur TRUE TRUE FALSE)
  61.             ()
  62.         )
  63.  
  64.  
  65.         (gimp-context-set-background inColor3)
  66.         (gimp-by-color-select thinLayer '(0 0 0) 127 CHANNEL-OP-REPLACE  TRUE FALSE 0 FALSE)
  67.         (gimp-edit-clear thinLayer)
  68.         (gimp-selection-invert theImage)
  69.         (gimp-edit-fill thinLayer BACKGROUND-FILL)
  70.         (gimp-selection-none theImage)
  71.         (if (= inSmooth TRUE)
  72.         (script-fu-tile-blur theImage thinLayer (/ theBlur 2) TRUE TRUE FALSE)
  73.             ()
  74.         )
  75.  
  76.  
  77.         (if (= inFlatten TRUE)
  78.             (gimp-image-flatten theImage)
  79.             ()
  80.     )
  81.  
  82.         (gimp-display-new theImage)
  83.  
  84.     (gimp-context-pop)))
  85.  
  86.  
  87. (script-fu-register "script-fu-camo-pattern"
  88.             _"_Camouflage..."
  89.             "Camouflage pattern"
  90.             "Chris Gutteridge: cjg@ecs.soton.ac.uk"
  91.             "28th April 1998"
  92.             "Chris Gutteridge / ECS @ University of Southampton, England"
  93.             ""
  94.             SF-ADJUSTMENT _"Image size"    '(256 10 1000 1 10 0 1)
  95.             SF-ADJUSTMENT _"Granularity"   '(7 0 15 1 1 0 0)
  96.             SF-COLOR      _"Color 1"       '(33 100 58)
  97.             SF-COLOR      _"Color 2"       '(170 170 60)
  98.             SF-COLOR      _"Color 3"       '(150 115 100)
  99.             SF-TOGGLE     _"Smooth"        FALSE
  100.             SF-TOGGLE     _"Flatten image" TRUE)
  101.  
  102. (script-fu-menu-register "script-fu-camo-pattern"
  103.              _"<Toolbox>/Xtns/Script-Fu/Patterns")
  104.